package se.ytterman.jserial.framework.device;

import java.lang.*;

import java.util.regex.*;

public class ResponsePattern {

    public ResponsePattern(String regexPattern, String responseId) throws Exception {
        // Compile regex pattern
	this.eventPattern = Pattern.compile(regexPattern);
        
        this.responseId = responseId;
    }
    
    public String getResponseId() {
        return this.responseId;        
    }
    
    public Matcher matchPattern(String testPattern) {
        // Create new matcher from pattern...
        Matcher eventMatcher = this.eventPattern.matcher(testPattern);     
        
	return eventMatcher;
    }
    
    public String toString() {
        String resultString = eventPattern.pattern() + "(" + this.responseId + ")";
        
        return resultString;
    }
    
    private Pattern eventPattern;
    private String responseId;
}
